package com.bwie.service.impl;

import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.domain.DouArea;
import com.bwie.service.DouAreaService;
import com.bwie.mapper.DouAreaMapper;
import com.bwie.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 36167
* @description 针对表【dou_area】的数据库操作Service实现
* @createDate 2025-03-13 19:48:37
*/
@Service
public class DouAreaServiceImpl extends ServiceImpl<DouAreaMapper, DouArea>
    implements DouAreaService{

    @Autowired
    DouAreaMapper douAreaMapper;


    @Override
    public R areashow() {
        List<DouArea> douAreas = douAreaMapper.selectList(null);
        List<Tree<String>> treeList = TreeUtil.build(douAreas, "0", ((douArea, tree) -> {
            tree.setId(douArea.getAreaId() + "");
            tree.setParentId(douArea.getParentId() + "");
            tree.setName(douArea.getName());
        }));
        return R.OK(treeList);
    }
}




